package com.hb.unic.websupport.config;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.hb.unic.core.util.ServletUtils;
import com.hb.unic.websupport.filter.BlackListAccessFilter;
import com.hb.unic.websupport.filter.TraceIdHttpFilter;

/**
 * 过滤器自动装配
 *
 * @since v1.0，2023/8/30 22:18，create by Mr.Huang.
 */
@Configuration
public class FilterAutoConfigurtion {

    /**
     * traceId过滤器
     *
     * @return 结果
     */
    @Bean
    public static FilterRegistrationBean<TraceIdHttpFilter> traceIdHttpFilter() {
        return ServletUtils.createFilter(new TraceIdHttpFilter(), "/*", "traceIdHttpFilter", true, Integer.MIN_VALUE);
    }

    /**
     * traceId过滤器
     *
     * @return 结果
     */
    @Bean
    public static FilterRegistrationBean<BlackListAccessFilter> blackListAccessFilter() {
        return ServletUtils.createFilter(new BlackListAccessFilter(), "/*", "blackListAccessFilter", true,
            Integer.MIN_VALUE + 100);
    }

}
